<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <body>
        <ui:composition template="../templates/default3.xhtml">  
            <ui:define name="content">
                <h:form id="addSalesForecast" binding="#{salesForecastManagerBean.loadAddSalesForecast}">

                    <p:messages id="error"/>
                  


                    <p:panel header="Simple sales forecast">

                        <table width="100%" border="0">
                             <tr>
                                <td width="80px">Product:</td>
                                <td width ="600px">
                                    <h:selectOneMenu id="selectOneProduct" value="#{salesForecastManagerBean.selectedProduct.code}">
                                        <f:selectItem itemLabel="Select Product" itemValue="" />
                                        <f:selectItems value="#{salesForecastManagerBean.products}" var="product" 
                                                       itemLabel="#{product.name}" itemValue="#{product.code}"/>
                                    </h:selectOneMenu>

                                </td>
                               
                            </tr>
                              <tr>
                                <td width="180px">
                                    Historical data:
                                </td>
                                <td width="250px">
                                    <h:selectOneMenu id="period" value="#{salesForecastManagerBean.period}">
                                        <f:selectItem  itemLabel="Current year" itemValue="0" />
                                        <f:selectItem  itemLabel="Include last year" itemValue="1" />
                                        <f:selectItem  itemLabel="Include five year" itemValue="4" />
                                        <f:selectItem  itemLabel="Include ten year" itemValue="9" />                                                       
                                    </h:selectOneMenu>
                                </td>
                              
                                 
                            </tr>
                             <tr>
                                <td>
                                    Aggregation: 
                                </td>
                                <td>
                                    <h:selectOneMenu id="aggregate" value="#{salesForecastManagerBean.aggregate}">
                                        <f:selectItem  itemLabel="Month" itemValue="Month" />
                                        <f:selectItem  itemLabel="Quarter" itemValue="Quarter" />
                                        <f:selectItem  itemLabel="Year" itemValue="Year" />           
                                    </h:selectOneMenu>
                                </td>
                            </tr>
                            
                            <tr>
                                <td width="180px">
                                    Annual growth (%):
                                </td>
                                <td width ="400px">
                                    <p:inputText id ="trend" value="#{salesForecastManagerBean.trend}" />

                                </td>

                              
                            </tr>
                            <tr>
                                <td>
                                   Annual growth:
                                </td>
                                <td>
                                    <h:selectOneRadio value="#{salesForecastManagerBean.trendMovement}">
                                        <f:selectItem  itemLabel="Upward" itemValue="1" />
                                        <f:selectItem  itemLabel="Downward" itemValue="0" />
                                    </h:selectOneRadio>

                                </td>


                               
                            </tr>
                            <tr>
                                <td></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center"><hr/>
                                    <p:commandButton id="btnCompute" value="Add Forecast" actionListener="#{salesForecastManagerBean.addSimple}" update="error" ajax="true" />
                                    <font size="1" color="green"></font>
                                </td>
                               

                            </tr>
                        </table>

                                <p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>  
                <p:dialog modal="true" widgetVar="statusDialog" header="Please wait..."   
                          draggable="false" closable="false" resizable="false" >
                    
                    
                    <p:graphicImage value="../resources/images/ajaxloadingbar.gif" /> 
                    </p:dialog>
                    


                    </p:panel>
                   

                    <p:panel header="Sales forecast (Regression)">

                    <table width="100%" border="0">

                        <tr>
                                <td width="120px">Product:</td>
                                <td width ="400px">
                                    <h:selectOneMenu id="selectOneProductR" value="#{salesForecastManagerBean.selectedProductR.code}">
                                        <f:selectItem itemLabel="Select Product" itemValue="" />
                                        <f:selectItems value="#{salesForecastManagerBean.products}" var="product" 
                                                       itemLabel="#{product.name}" itemValue="#{product.code}"/>
                                    </h:selectOneMenu>

                                </td>
                               
                            </tr>
                        
                        <tr>
                            <td valign="top">
                                Variable 1:
                            </td>
                          
                            <td>   
                                Name: <p:inputText id ="x1" value="#{salesForecastManagerBean.x1_str}" />
                                <br/>
                                File: &nbsp;&nbsp; <p:inputText id ="file1" value="#{salesForecastManagerBean.filepath1}" />
                            </td>
                        </tr>
                        
                         <tr>
                            <td valign="top">
                                Variable 2:
                            </td>
                            <td>   
                                Name: <p:inputText id ="x2" value="#{salesForecastManagerBean.x2_str}" />
                                <br/>
                                File: &nbsp;&nbsp; <p:inputText id ="file2" value="#{salesForecastManagerBean.filepath2}" />
                            </td>
                        </tr>
                         <tr>
                            <td valign="top">
                                Variable 3:
                            </td>
                            <td>   
                                Name: <p:inputText id ="x3" value="#{salesForecastManagerBean.x3_str}" />
                                <br/>
                                File: &nbsp;&nbsp; <p:inputText id ="file3" value="#{salesForecastManagerBean.filepath3}" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center"><hr/>
                              <p:commandButton id="btnCompute2" value="Add Forecast" actionListener="#{salesForecastManagerBean.addRegression}" update="error" ajax="true" />
                            </td>
                        </tr>
                 
                        
                    </table>
                        
                        
                        
                    </p:panel>


                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>